﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using System.Drawing.Printing;
using System.Windows.Documents;

namespace easy_sportident_print
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            populatePrinterSelectBox();
        }
        private void button_selectprinter_Click(object sender, EventArgs e)
        {
            printDialog.ShowDialog();
        }
        private void populatePrinterSelectBox()
        {
            foreach (string s in PrinterSettings.InstalledPrinters)
            {
                comboBox_printers.Items.Add(s);
            }
            comboBox_printers.SelectedIndex = 0;
        }
        private void printTest()
        {
            PrintDocument pd = new PrintDocument();
            pd.PrinterSettings.PrinterName = comboBox_printers.SelectedItem.ToString();
            pd.PrintController = new StandardPrintController();
            pd.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage);
            pd.Print();
        }
        private void printDocument1_PrintPage(object sender,System.Drawing.Printing.PrintPageEventArgs e)
        {
            //e.Graphics.FillRectangle(Brushes.Blue,new Rectangle(100, 150, 250, 250));
            e.Graphics.DrawString("Printer working just fine", new Font("Arial", 14), new SolidBrush(Color.Black), new PointF(50.0F, 150.0F));
        }
        private void button_printTest_Click(object sender, EventArgs e)
        {
            printTest();
        }
    }
}
